const app = getApp()
Page({

  /**
   * 页面的初始数据
   */
  data: {

  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    wx.showLoading({
      title: '加载中...',
    })
    let access_token = wx.getStorageSync('access_token')
    wx.request({
      url: 'https://baokang.wshoto.com/wx/comlist',
      data: {
        access_token: access_token,
      },
      success: (res) => {
        console.log(res.data)
        if(res.data.code >= 500){
          app.getLogin().then(function(){
            console.log('二次登录。。。')
          })
        } 
        else if (res.data.code == 1) {
          this.setData({
            comlist: res.data.list
          })
        }
      },
      complete:(res)=>{
        wx.hideLoading()
      }
    })
  },

  toDetails(e) {
    let c_id = e.currentTarget.dataset.id
    let name = e.currentTarget.dataset.name
    wx.navigateTo({
      url: '../social-details/social-details?c_id=' + c_id + '&c_name=' + name
    })
  },
})